/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-17 14:00:30
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalTime;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_edu_certificate")
@SQLDelete(sql = "update wwyt_edu_certificate set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_edu_certificate set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class EduCertificate implements java.io.Serializable {

    //columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    //ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    //名称
    @Column(name = "NAME", length = 100, nullable = false)
    private String name;

    //编号
    @Column(name = "CODE", length = 30, nullable = false)
    private String code;

    //证书有效期类型
    @Column(name = "EFFECTIVE_TYPE")
    private Byte effectiveType;

    //培训有效期（月）
    @Column(name = "EFFECTIVE_DURATION_MONTH")
    private Integer effectiveDurationMonth;

    //状态
    @Column(name = "STATE")
    private Byte state;

    //是否到期提醒 0 否 ; 1 是
    private Integer expireRemindOrNot;
    //到期提醒类型
    private String remindType;
    //提醒时间
    private LocalTime remindTime;
    //提醒人和部门互斥
    //提醒人可以多个
    private String remindUserIdsJson;
    //提醒部门
    private Long departId;

    @Column(name = "USE_STATE")
    //启用状态 0-启用/1-停用
    private Integer useState;
    //创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    //创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    //更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    //更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    //删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    //组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    //租户
    @Column(name = "TENENT_ID")
    private Long tenentId;
    //columns END

    @ApiModelProperty("证书类型--数据字典维护")
    private Long certTypeId;
    @ApiModelProperty("发证机构")
    private String releaseOrganization;

    public int hashCode() {
        return new HashCodeBuilder()
                .append(getId())
                .toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof EduCertificate == false) return false;
        if (this == obj) return true;
        EduCertificate other = (EduCertificate) obj;
        return new EqualsBuilder()
                .append(getId(), other.getId())
                .isEquals();
    }
}

